/*
 * GeoVISTA Center (Penn State, Dept. of Geography)
 * Copyright (c), 2003-2011,  Jin Chen and Alan M. MacEachren, GeoVISTA Center, Penn State University
 * Licensed under Simplified BSD License
 *
 *
 * @author: jin Chen 
 * @date: May 30, 2005$
 * @version: 1.0
 */
package edu.psu.geovista.app.hce.clustering.hierarchical.linkage;

import edu.psu.geovista.app.hce.clustering.model.BCluster;


public class SingleLink extends AbstractLinkageMethod{
    //DialogMatrixFloat
    public double similarity(BCluster cls1, BCluster cls2)  {
        int[] ids1 = cls1.getIds(); //id of all observations contained in this cluster and its children cluster
        int[] ids2 = cls2.getIds(); //id of all observations contained in this cluster and its children cluster
        double maxSim=simMatrix.get(ids1[0], ids2[0]);// 
        for (int i=0;i<ids1.length ;i++){
            for (int j=0;j<ids2.length ;j++){
                double sim=simMatrix.get(ids1[i], ids2[j]);
                if ( sim>maxSim){
                    maxSim=sim;
                }
            }
        }
       return maxSim;

    }
}
